package com.seveneight.baijiesteward.adapter;

import android.content.Context;
import android.util.DisplayMetrics;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.seveneight.baijiesteward.R;
import com.seveneight.baijiesteward.bean.MenuBean;
import com.seveneight.baijiesteward.http.HttpConfig;
import com.seveneight.baijiesteward.utils.GlideLoader;
import com.seveneight.baijiesteward.utils.LogUtil;

/**
 * Created by user1 on 2018/2/8.
 */

public class FirstAdapter extends ListBaseAdapter<MenuBean> {

    private Context context;

    public FirstAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public int getLayoutId() {
        return R.layout.item_icon;
    }

    @Override
    public void onBindItemHolder(SuperViewHolder holder, int position) {
        LinearLayout layout_content = holder.getView(R.id.layout_content);
        ImageView iv_icon = holder.getView(R.id.iv_icon);
        TextView tv_iconname = holder.getView(R.id.tv_iconname);
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        int width = dm.widthPixels;
        LinearLayout.LayoutParams linearParams = (LinearLayout.LayoutParams) layout_content.getLayoutParams();
        linearParams.height = width / 4;
        linearParams.width = width / 4;
        layout_content.setLayoutParams(linearParams);
        MenuBean bean = mDataList.get(position);
        GlideLoader.displayImg(mContext, HttpConfig.SOURCE_URL+bean.getIcoUrl().toString(),iv_icon);
        LogUtil.d("menuIcon:"+HttpConfig.SOURCE_URL+bean.getIcoUrl());
        tv_iconname.setText(bean.getModuleName());
    }
}
